<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Get\Controller;
use Think\Controller;
class RegisterController extends Controller {
	
	public function indexAction(){
		if(C('sitecloseregister')){
			$this->ajaxReturn(array('title'=>'注册失败','message'=>'网站注册暂时关闭！','status'=>'error','json'));
			return false;
		}
		$user = new \Register\Model\MemberModel();
		if($id=$user->RegisterSubmit()){
			$this->ajaxReturn(array('title'=>'注册成功','message'=>$user->getSuccess(),'status'=>'ok','refresh'=>true,'url'=>U('/register/verify/id/'.$id),$_POST['datatype']));
		}else{
			$this->ajaxReturn(array('title'=>'注册失败','message'=>$user->getError(),'status'=>'error','data'=>$user->getError()),$_POST['datatype']);
		}

	}
	
	function sendcodeAction(){
		if(C('sitecloseregister')){
			$this->ajaxReturn(array('title'=>'注册失败','message'=>'网站注册暂时关闭！','status'=>'error','json'));
			return false;
		}
		
		$memberverify = new \Register\Model\MemberVerifyModel();
		if($memberverify->SendCode()){
			$this->ajaxReturn(array('title'=>'发送成功','message'=>$memberverify->getSuccess(),'status'=>'ok','refresh'=>true,$_POST['datatype']));
		}else{
			$this->ajaxReturn(array('title'=>'发送失败','message'=>$memberverify->getError(),'status'=>'error',$_POST['datatype']));
		}

	}
    
}